import request from '@/utils/request'
/**
 * 获取角色列表
 * ***/
export const getRoleListApi = (page, pagesize) => {
  return request({
    method: 'get',
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}

/**
 * 删除角色
 ***/
export const deleteRoleApi = (id) => {
  return request({
    url: `/sys/role/${id}`,
    method: 'delete'
  })
}

/** *
 * 新增角色
 * ***/
export const addRoleApi = (data) => {
  return request({
    url: '/sys/role',
    data,
    method: 'post'
  })
}
/**
 * 根据 id 获取角色详情, 用于回显
 * **/
export const getRoleDetailApi = (id) => {
  return request({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

/**
 *修改角色
 * **/
export const editRoleApi = (data) => {
  return request({
    method: 'put',
    url: `/sys/role/${data.id}`,
    data
  })
}

// 根据 id 查询企业
export const getCompanyInfoApi = (id) => {
  return request({
    method: 'get',
    url: `/company/${id}`
  })
}

/**
 * 给角色分配权限
 * @param {*} data 所需参数
 * @returns
 */
export const assignPermApi = data => {
  return request({
    url: '/sys/role/assignPrem',
    method: 'put',
    data
  })
}
